<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //Promise：异步操作的一种方案
        //Promise一般是用来解决层层嵌套的回调函数(回调地狱callback hell)的问题

        //实例化构造函数生成的对象
        // const p = new Promise(() => {

        //   });

        //Promise的三种状态
        //pending( 未完成)
        //执行resolve 变成fulfilled( resolved)已成功  由pending变成 resolved
        //执行reject 变成rejected已失败   由pending变成 rejected
        //Promise的状态一旦变化 就不会再改变了

        const p = new Promise((resolve, reject) => {

            resolve();
            //reject()

        });
        console.log(p);

        //then()方法
        p.then(() => {
            console.log('success');
        }, () => {
            console.log('error');
        })


        //resolve和reject函数的参数
    </script>
</body>

</html>